package com.google.code.wicket.auth.component.value.resolver;

import java.util.Collection;

/**
 * Determines what values are required for a given component class. Usage:
 * Implement either {@link #getSingleValue(Class)} or {@link #getValues(Class)}
 * and let {@link #useSingleValues()} determine which one you are using. (Use
 * {@link SingleValueResolver} and {@link MultiValueResolver} as adapters so
 * that you only have to implement one method).
 * 
 * @param <T>
 *            the value type, will usually be a string or an enum representing a
 *            role or privilege.
 */
public interface ValueResolver<T> {

    /**
     * Get a single required value.
     * 
     * @param componentClass
     * @return
     */
    T getSingleValue(Class<?> componentClass);

    /**
     * Get all required values.
     * 
     * @param componentClass
     * @return
     */
    Collection<T> getValues(Class<?> componentClass);

    /**
     * If this returns true, clients must call {@link #getSingleValue(Class)},
     * otherwise {@link #getValues(Class)}.
     * 
     * @return
     */
    boolean useSingleValues();

}
